package com.itheima.homework;

import java.util.Random;
import java.util.Scanner;

public class TestMyRectange {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入矩形长度");
        double height = sc.nextDouble();
        System.out.println("请输入矩形宽度");
        double width = sc.nextDouble();
        MyRecatangle r = new MyRecatangle();
        r.setHeight(height);
        r.setWidth(width);
        MyRecatangle r2 =new MyRecatangle( height,width);
        r.perimeter();
        r.area();
        r2.perimeter();
        r2.area();
    }
}
class MyRecatangle{
    private double height;
    private double width;

    public MyRecatangle(){}
    public MyRecatangle(double height,double width){
        this.height = height;
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public void perimeter(){

        System.out.println("矩形的周长为:" + (height * 2+ width * 2) + "cm");
    }
    public void area(){

        System.out.println("矩形的面积为:" + height * width + "cm");
    }
}